//
/* AdminHomePanel.java 
 *      This is the main AdminHomePanel for admin users (could change depending on how we implement the user access control)
 *  
 *  The main AdminHomePanel window is a JPanel
 *      
 *    Components within the JPanel
 *      - JTabbedPane with each of the following Panels
 *        * CurrentClientsPanel.java           - Lists current patients in a sortable table. 
 *                                                                                      Once a User is selected, a window will pop up with their file
 *        * Add/Admit Patients                          - Starts the Screening Process or Admits a patient that has been prescreened
 *        * Reports (only for admin users)      - Screen for generating and printing organizational statistics/reports
 *        * Administration                                  - Add/Remove users
 * 
 * */
         
import javax.swing.JButton;
import javax.swing.JTabbedPane;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.KeyEvent;
         
        public class AdminHomePanel extends JPanel {
                 private JPanel currentPatientsPanel; 
                 private JPanel addAdmitPanel;
                 private JPanel reportsPanel;
                 private JPanel adminPanel;
					  
                 
                 private JButton logoutButton;          //will be added as a button with absolute positioning
                
                 /** AdminHomePanel Constructor **/
            public AdminHomePanel() {
                        this.setBackground(Color.WHITE); //sets the main window to white  
                                        
                //TabbedPane and Components of GUI 
                JTabbedPane tabbedPane = new JTabbedPane();
                ImageIcon icon = createImageIcon("images/icon.png");
                 
                currentPatientsPanel = new CurrentClientsPanel(); //CurrentPatientsPanel 
                tabbedPane.addTab("Current Patients", icon, currentPatientsPanel,
                        "List of Current Patients at WSR");             
                      
                tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);
                 
                addAdmitPanel = new AddAdmitPanel(); //Charlie Thao changed this to create an object of a class I made
					 addAdmitPanel.setBackground(Color.WHITE); 
                tabbedPane.addTab("Add/Admit Patients", icon, addAdmitPanel,
                        "Begin Screening Process or Admit a Pre-Screened Patient");
                tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);
                 
                JPanel reportsPanel = new JPanel(); 
                tabbedPane.addTab("Reports", icon, reportsPanel,
                        "Exporting WSR Organizational Reports and Statistics");
                tabbedPane.setMnemonicAt(2, KeyEvent.VK_3);
                 
                JPanel adminPanel = new JPanel(); 
                tabbedPane.addTab("Administration", icon, adminPanel,
                        "Creating Employees / Deleting Employees / Viewing System Information and Logs");
                tabbedPane.setMnemonicAt(3, KeyEvent.VK_4);                   
                                
                //tabbedPane font
                        tabbedPane.setFont(new Font("Arial", Font.PLAIN, 14));      
                        
                //logout Button
                        logoutButton = new JButton("Logout");
                        logoutButton.setLayout(null); // allows us to put the button wherever we wish in the window
                        logoutButton.setSize(new Dimension(50,50));
                        //add(logoutButton);
                
                //Add components to this panel (home window using GridBagLayout).
                        //layout
                        //(1 row, 2 columns)                                    column 1                                        column 2        
                        //                                      row 1   | [---------tabbedPane----------] | [logoutframe]  | 
               GridBagConstraints c = new GridBagConstraints();
                    
                    c.anchor = GridBagConstraints.NORTHWEST;
                    c.weightx = 1; //space to allocate to cell [half a cell]
                    c.weighty = 1;
                    c.gridx = 0; //x coordinate
                    c.gridy = 0; //y coordinate
                add(tabbedPane, c); //tabbedPane
                
                c.anchor = GridBagConstraints.FIRST_LINE_START;
                c.gridx = 1;
                c.gridy = 0;
                c.weightx = .1; //space to allocate to cell [half a cell]
                    c.weighty = .1;
                add(logoutButton, c);;
                
                
                
                 
                //The following line enables to use scrolling tabs.
                tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
            }
            
            
            /** Returns an ImageIcon, or null if the path was invalid. */
            protected static ImageIcon createImageIcon(String path) {
                java.net.URL imgURL = AdminHomePanel.class.getResource(path);
                if (imgURL != null) {
                    return new ImageIcon(imgURL);
                } else {
                    System.err.println("Couldn't find file: " + path);
                    return null;
                }
            }
             
            
            /** Create the GUI and show it. **/
            private static void createAndShowGUI() {
                //Create and set up the window.
                JFrame frame = new JFrame("West Slope Recovery - ITRDB");
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                //Add content to the window.
                frame.add(new AdminHomePanel(), BorderLayout.CENTER);
                 
                //Display the window.
                frame.setSize(new Dimension(800,600));
                frame.setVisible(true);
            }
             
            /** main() **/
            public static void main(String[] args) {
                     
                /* Set the Nimbus look and feel */
                try {
                    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                        if ("Nimbus".equals(info.getName())) {
                            UIManager.setLookAndFeel(info.getClassName());
                            break;
                        }
                    }
                } catch (Exception e) {
                    // If Nimbus is not available, you can set the GUI to another look and feel.
                }

                /* Create and display the form */
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                    createAndShowGUI();
                    }
                });
            }
            
            
}                                  